<!doctype html>
<html>
	<head>
		<title></title>
		<meta charset = "utf-8"/>
	</head>
	<style type="text/css">
		*{
			margin:0px;
			padding:0px;
		}
	</style>
<body>
	用户名：<input id="username" type="text"  /><br/>
	密　码：<input id="userpass" type="password" /><br/>
	<input id="btnLogin" type="button" value="登录" />
	<div id="messageBox">
	</div>
</body>
</html>
<script type="text/javascript" src="js/cookieTools.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	$(function(){		
		$("#btnLogin").click(function(){
			$.post(
				"login.php",
				{
					"username":$("#username").val(),
					"userpass":$("#userpass").val()
				},
				function(data){
					if(data=="success"){
						$("#messageBox").html("亲，恭喜您，登录成功！2秒后跳转到<a href='index.html'>首页</a>！");
						//保存cookie：
						saveCookie("username",$("#username").val());
						setTimeout(()=>{
							location.href="index.html";
						},2000);
					}else if(data=="fail"){
						$("#messageBox").html("不好意思，亲，用户名或者密码错误！");
					}else{
						$("#messageBox").html("不好意思，亲，服务器出错了！");
					}
				}
			);
		});
	});
	
</script>
